package com.wh.order.controller;

import com.wh.order.service.IOrderPetAcquisitionService;
import com.wh.order.pojo.OrderPetAcquisition;
import com.wh.order.dto.OrderPetAcquisitionDto;
import com.wh.basic.vo.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* 后端接口类；
*/
@RestController
@RequestMapping("/orderPetAcquisition")
public class OrderPetAcquisitionController {

    @Autowired
    public IOrderPetAcquisitionService orderPetAcquisitionService;

    /**
    * 接口：查询所有
    * @return
    */
    @GetMapping
    public List<OrderPetAcquisition> findAll() {
        return orderPetAcquisitionService.findAll();
    }


    /**
     * 接口：分页查询或高级查询
     * @param orderPetAcquisitionDto 查询对象
     * @return IPage<OrderPetAcquisition> 分页对象
     */
    @PostMapping
    public IPage<OrderPetAcquisition> findByPage(@RequestBody OrderPetAcquisitionDto orderPetAcquisitionDto, HttpServletRequest request) {
        return orderPetAcquisitionService.findByPage(orderPetAcquisitionDto,request);
    }
    @GetMapping(value="/cancel/{id}")
    public AjaxResult cancel(@PathVariable("id") Long id){
        orderPetAcquisitionService.cancel(id);
        return new AjaxResult();
    }
    /**
     * 确认订单
     * @param orderPetAcquisition
     * @return
     */
    @PostMapping("/confirm")
    public AjaxResult confirm(@RequestBody OrderPetAcquisition orderPetAcquisition){
        orderPetAcquisitionService.confirm(orderPetAcquisition);
        return new AjaxResult();
    }

}
